package entity

import (
	"time"

	"github.com/jinzhu/gorm"
	log "github.com/sirupsen/logrus"
	"shqsoft.cn/pasnj/base"
)

//结算量
type Settlement struct {
	ID      int        `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	FSRQ    *time.Time `gorm:"column:FSRQ"`
	HM      string     `gorm:"column:HM"`
	ZJJGDM  string     `gorm:"column:ZJJGDM"`
	XL      string     `gorm:"column:XL"`
	ORGNAME string     `gorm:"column:ORGNAME"`
	NAME    string     `gorm:"column:NAME"`
	ZB      float64    `gorm:"column:ZB"`
	BZ      string     `gorm:"column:BZ"`
	JE      float64    `gorm:"column:JE"`
	YZ      string     `gorm:"column:YZ"`
	SY      string     `gorm:"column:SY"`
	ZSL     float64    `gorm:"column:ZSL"`
	ZMY     float64    `gorm:"column:ZMY"`
	ZSL2    float64    `gorm:"column:ZSL2"`
	ZRMB    float64    `gorm:"column:ZRMB"`
}

//TableName 结算量
func (Settlement) TableName() string {
	return "T_BASE_JSL"
}

// 导入后执行分户处理
func JxkhJSLAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	tx.Exec("EXEC UP_BASE_JSL")
	log.Debug("成功！")
	return nil
}

func SettlementEF() base.EntityFunc {
	return func() interface{} {
		entity := Settlement{}
		return &entity
	}
}
func SettlementESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []Settlement
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("Settlement", base.NewDefaultDao(SettlementEF(), SettlementESF(), nil))
	base.SetAfterCallBack("Settlement", JxkhJSLAfterImport)
}
